/* 
 * File:   MsgCounters.h
 * Author: lusitanio
 *
 * Created on 21 de Fevereiro de 2012, 22:17
 */

#ifndef MSGCOUNTERS_H
#define	MSGCOUNTERS_H

class MsgCounters {
private:
    //Sensor
    int id;
    //Mensagens Enviadas
    //Próprias
    int sa_out;
    int sum_out;
    int data_out;
    int query_out;
    int reply_out;
    //Encaminhamento
    int sa_out_enc;
    int sum_out_enc;
    int data_out_enc;
    int query_out_enc;
    int reply_out_enc;

    //Mensagens recebidas 
    //Destino Final
    int sa_in_final;
    int sum_in_final;
    int data_in_final;
    int query_in_final;
    int reply_in_final;
    //Encaminhamento
    int sa_in_enc;
    int sum_in_enc;
    int data_in_enc;
    int query_in_enc;
    int reply_in_enc;



public:

    MsgCounters(int id_ = -1) {
        this->id = id_;
        reset();
    }

    void reset() {
        //Mensagens Enviadas
        //Próprias
        this->sa_out = 0;
        this->sum_out = 0;
        this->data_out = 0;
        this->query_out = 0;
        this->reply_out = 0;
        //Encaminhamento
        this->sa_out_enc = 0;
        this->sum_out_enc = 0;
        this->data_out_enc = 0;
        this->query_out_enc = 0;
        this->reply_out_enc = 0;

        //Mensagens recebidas 
        //Destino Final
        this->sa_in_final = 0;
        this->sum_in_final = 0;
        this->data_in_final = 0;
        this->query_in_final = 0;
        this->reply_in_final = 0;
        //Encaminhamento
        this->sa_in_enc = 0;
        this->sum_in_enc = 0;
        this->data_in_enc = 0;
        this->query_in_enc = 0;
        this->reply_in_enc = 0;
    }

    //GETS
    int getData_in_enc() const {
        return data_in_enc;
    }

    int getData_in_final() const {
        return data_in_final;
    }

    int getData_out() const {
        return data_out;
    }

    int getData_out_enc() const {
        return data_out_enc;
    }

    int getId() const {
        return id;
    }

    int getQuery_in_enc() const {
        return query_in_enc;
    }

    int getQuery_in_final() const {
        return query_in_final;
    }

    int getQuery_out() const {
        return query_out;
    }

    int getQuery_out_enc() const {
        return query_out_enc;
    }

    int getReply_in_enc() const {
        return reply_in_enc;
    }

    int getReply_in_final() const {
        return reply_in_final;
    }

    int getReply_out() const {
        return reply_out;
    }

    int getReply_out_enc() const {
        return reply_out_enc;
    }

    int getSa_in_enc() const {
        return sa_in_enc;
    }

    int getSa_in_final() const {
        return sa_in_final;
    }

    int getSa_out() const {
        return sa_out;
    }

    int getSa_out_enc() const {
        return sa_out_enc;
    }

    int getSum_in_enc() const {
        return sum_in_enc;
    }

    int getSum_in_final() const {
        return sum_in_final;
    }

    int getSum_out() const {
        return sum_out;
    }

    int getSum_out_enc() const {
        return sum_out_enc;
    }
    

    //INCREMENTAR MSGS
    //SA

    void IncSa_in_final() {
        this->sa_in_final++;
    }

    void IncSa_in_enc() {
        this->sa_in_enc++;
    }

    void IncSa_out() {
        this->sa_out++;
    }

    void IncSa_out_enc() {
        this->sa_out_enc++;
    }
    //DATA

    void IncData_in_enc() {
        this->data_in_enc++;
    }

    void IncData_in_final() {
        this->data_in_final++;
    }

    void IncData_out() {
        this->data_out++;
    }

    void IncData_out_enc() {
        this->data_out_enc++;
    }

    //SUM

    void IncSum_in_enc() {
        this->sum_in_enc++;
    }

    void IncSum_in_final() {
        this->sum_in_final++;
    }

    void IncSum_out() {
        this->sum_out++;
    }

    void IncSum_out_enc() {
        this->sum_out_enc++;
    }

    //QUERY

    void IncQuery_in_enc() {
        this->query_in_enc++;
    }

    void IncQuery_in_final() {
        this->query_in_final++;
    }

    void IncQuery_out() {
        this->query_out++;
    }

    void IncQuery_out_enc() {
        this->query_out_enc++;
    }

    //REPLY

    void IncReply_in_final() {
        this->reply_in_final++;
    }

    void IncReply_in_enc() {
        this->reply_in_enc++;
    }

    void IncReply_out() {
        this->reply_out++;
    }

    void IncReply_out_enc() {
        this->reply_out_enc++;
    }
    
    //TOTAIS RECEBIDOS

    int GetMsgs_total_in_enc() const {
        return ( sa_in_enc + sum_in_enc + data_in_enc + query_in_enc + reply_in_enc);
    }

    int GetMsgs_total_in_own() const {
        return (sa_in_final + sum_in_final + data_in_final + query_in_final + reply_in_final);
    }

    int GetMsgs_total_in() const {
        return (this->GetMsgs_total_in_enc() + this->GetMsgs_total_in_own());
    }

    //TOTAIS ENVIADOS
    int GetMsgs_total_out_enc() const {
        return ( sa_out_enc + sum_out_enc + data_out_enc + query_out_enc + reply_out_enc);
    }

    int GetMsgs_total_out_own() const {
        return ( sa_out + sum_out + data_out + query_out + reply_out);
    }

    int GetMsgs_total_out() const {
        return (this->GetMsgs_total_out_enc() + this->GetMsgs_total_out_own());
    }

    void print() {
        print_in();
        print_out();
    }

    void print_in_enc() {
//        printf("#### Mensagens recebidas - P/encaminhar [%d] ####\n", this->id);
//        printf("## MAPPING -> %4d\n", sa_in_enc);
//        printf("## SUMMARY -> %4d\n", sum_in_enc);
//        printf("## DATA    -> %4d\n", data_in_enc);
//        printf("## QUERY   -> %4d\n", query_in_enc);
//        printf("## REPLY   -> %4d\n", reply_in_enc);
//        printf("#### Total -> %4d ####\n", GetMsgs_total_in_enc());
        printf("##[MSGS - RECV - FW [%2d]][MAPPING: %4d][SUMMARY: %4d][DATA: %4d][QUERY: %4d][REPLY: %4d][TOTAL: %4d]\n",id,sa_in_enc,sum_in_enc,data_in_enc,query_in_enc,reply_in_enc,GetMsgs_total_in_enc());
    }

    void print_in_own() {
//        printf("#### Mensagens recebidas - Destino final [%d] ####\n", this->id);
//        printf("## MAPPING -> %4d\n", sa_in_final);
//        printf("## SUMMARY -> %4d\n", sum_in_final);
//        printf("## DATA    -> %4d\n", data_in_final);
//        printf("## QUERY   -> %4d\n", query_in_final);
//        printf("## REPLY   -> %4d\n", reply_in_final);
//        printf("#### Total -> %4d ####\n", GetMsgs_total_in_own());
        printf("##[MSGS - RECV - OWN[%2d]][MAPPING: %4d][SUMMARY: %4d][DATA: %4d][QUERY: %4d][REPLY: %4d][TOTAL: %4d]\n",id,sa_in_final,sum_in_final,data_in_final,query_in_final,reply_in_final,GetMsgs_total_in_own());
    }

    void print_in() {
//        printf("###### MENSAGENS RECEBIDAS - TOTAL [%d] ######\n", this->id);
        this->print_in_enc();
        this->print_in_own();
//        printf("###### TOTAL RECEBIDO -> %4d ######\n", GetMsgs_total_in());
        printf("##[MSGS - RECV - TTL[%2d]][MAPPING: %4d][SUMMARY: %4d][DATA: %4d][QUERY: %4d][REPLY: %4d][TOTAL: %4d]\n\n",id,sa_in_final+sa_in_enc,sum_in_final+sum_in_enc,data_in_final+data_in_enc,query_in_final+query_in_enc,reply_in_final+reply_in_enc,GetMsgs_total_in());
        

    }

    void print_out_enc() {
//        printf("#### Mensagens Enviadas - Encaminhadas [%d] ####\n", this->id);
//        printf("## MAPPING -> %4d\n", sa_out_enc);
//        printf("## SUMMARY -> %4d\n", sum_out_enc);
//        printf("## DATA    -> %4d\n", data_out_enc);
//        printf("## QUERY   -> %4d\n", query_out_enc);
//        printf("## REPLY   -> %4d\n", reply_out_enc);
//        printf("#### Total -> %4d ####\n", GetMsgs_total_out_enc());
        printf("##[MSGS - SEND - FW [%2d]][MAPPING: %4d][SUMMARY: %4d][DATA: %4d][QUERY: %4d][REPLY: %4d][TOTAL: %4d]\n",id,sa_out_enc,sum_out_enc,data_out_enc,query_out_enc,reply_out_enc,GetMsgs_total_out_enc());
    }

    void print_out_own() {
//        printf("#### Mensagens Enviadas - Próprias [%d] ####\n", this->id);
//        printf("## MAPPING -> %4d\n", sa_out);
//        printf("## SUMMARY -> %4d\n", sum_out);
//        printf("## DATA    -> %4d\n", data_out);
//        printf("## QUERY   -> %4d\n", query_out);
//        printf("## REPLY   -> %4d\n", reply_out);
//        printf("#### Total -> %4d ####\n", GetMsgs_total_out_own());
        printf("##[MSGS - SEND - OWN[%2d]][MAPPING: %4d][SUMMARY: %4d][DATA: %4d][QUERY: %4d][REPLY: %4d][TOTAL: %4d]\n",id,sa_out,sum_out,data_out,query_out,reply_out,GetMsgs_total_out_own());

    }

    void print_out() {
//        printf("###### MENSAGENS ENVIADAS - TOTAL [%d] ######\n", this->id);
        this->print_out_enc();
        this->print_out_own();
//        printf("###### TOTAL ENVIADO-> %4d ######\n", this->GetMsgs_total_out());
        printf("##[MSGS - SEND - TTL[%2d]][MAPPING: %4d][SUMMARY: %4d][DATA: %4d][QUERY: %4d][REPLY: %4d][TOTAL: %4d]\n\n",id,sa_out+sa_out_enc,sum_out+sum_out_enc,data_out+data_out_enc,query_out+query_out_enc,reply_out+reply_out_enc,GetMsgs_total_out());

    }

};

#endif	/* MSGCOUNTERS_H */

